from none_bot_py_plugins.net.socket_main import *
from none_bot_py_plugins.mod.login import login_handle

handle_mod = {
    1: "system"
}


def mod_handler(user_loop: ServerLoop, proto_object):
    global handle_mod
    msg_id = mod_msg.s2c_mod2msg[class_full_name(proto_object)]
    handle_mod_name = handle_mod[msg_id // 1000]
    handle_mod = "%s_handle" % handle_mod_name
    if msg_id == 1:
        ret_msgs = getattr(globals()[handle_mod], "recv_handle")(proto_object, user_loop)
    else:
        ret_msgs = getattr(globals()[handle_mod], "recv_handle")(proto_object, user_loop.player)
    if ret_msgs is not None and len(ret_msgs) > 0:
        for ret_msg in ret_msgs:
            user_loop.ret_client(ret_msg)
    return True
